package org.krivtsun.jpref;

import javax.swing.*;
import java.awt.*;
import java.awt.geom.RoundRectangle2D;
import java.awt.image.BufferedImage;

abstract class Gamer extends JComponent {

    protected static final int BORDER = 10;

    Gamer() {
        setOpaque(false);
    }

    public abstract void addCard(Card card);

    public Component getViewComponent() {
        return this;
    }

    protected abstract BufferedImage getCardImage(Card card);

    protected void drawCard(BufferedImage img, Graphics g, int x, int y) {
        Shape oldS = g.getClip();
        Shape s = new RoundRectangle2D.Double(x, y, img.getWidth() - 1, img.getHeight() - 1, 9, 9);
        g.setClip(s);
        g.drawImage(img, x, y, null);
        g.setClip(oldS);

        g.setColor(Color.black);
        g.drawRoundRect(x, y, img.getWidth() - 1, img.getHeight() - 1, 9, 9);
    }
}
